[slug].vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <script lang='ts' setup>
  2. import { Api } from '@/api/model/url'
  3. import { useCommonStore } from '@/stores/modules/common'
  4. import { Condition } from '@/enums/const-enums'
  5. import { useUserStore } from '@/stores/modules/user'
  6. const { openLoginModal } = useLoginModal()
  7. const userStore = useUserStore()
  8. const { isLogin } = storeToRefs(userStore)
  9. const config = useRuntimeConfig()
  10. const { apiBaseSiteUrl } = config.public
  11. const route = useRoute()
  12. const detail = ref<any>({})
  13. const tabValue = ref('blog')
  14. const isHasCatalogue = ref(true)
  15. const options = ref([
  16. {
  17. label: 'Read Blog',
  18. value: 'blog',
  19. },
  20. {
  21. label: 'Preview Catalog',
  22. value: 'catalog',
  23. },
  24. ])
  25. const slug = route.params.slug
  26. const { data, pending, error, refresh } = await useAsyncData(
  27. 'blog-detail',
  28. () =>
  29. $fetch(`${apiBaseSiteUrl}${Api.BlogDetail}`, { params: { slug } }),
  30. )
  31. const seoData = data.value?.result
  32. // 把createTime和updateTime转换为ISO格式
  33. if (seoData?.createTime)
  34. seoData.createTime = new Date(seoData.createTime).toISOString()
  35. if (seoData?.updateTime)
  36. seoData.updateTime = new Date(seoData.updateTime).toISOString()
  37. if (!seoData?.relatedCatalogue)
  38. isHasCatalogue.value = false
  39. detail.value = seoData
  40. useHead({
  41. title: detail.value?.metaTitle,
  42. meta: [
  43. {
  44. name: 'description',
  45. content: detail.value?.metaDescribe,
  46. },
  47. {
  48. property: 'og:title',
  49. content: detail.value?.metaTitle,
  50. },
  51. {
  52. property: 'og:description',
  53. content: detail.value?.metaDescribe,
  54. },
  55. {
  56. property: 'og:image',
  57. content: detail.value?.thumbnailUrl,
  58. },
  59. {
  60. property: 'og:url',
  61. content: `${apiBaseSiteUrl}/blog/${slug}`,
  62. },
  63. {
  64. property: 'og:type',
  65. content: 'website',
  66. },
  67. {
  68. property: 'twitter:title',
  69. content: detail.value?.metaTitle,
  70. },
  71. {
  72. property: 'twitter:description',
  73. content: detail.value?.metaDescribe,
  74. },
  75. {
  76. property: 'twitter:site',
  77. content: `${apiBaseSiteUrl}/blog/${slug}`,
  78. },
  79. {
  80. property: 'twitter:image',
  81. content: detail.value?.thumbnailUrl,
  82. },
  83. {
  84. property: 'twitter:card',
  85. content: 'summary_large_image',
  86. },
  87. ],
  88. script: [
  89. // JSON-LD
  90. {
  91. type: 'application/ld+json',
  92. children: JSON.stringify({
  93. datePublished: detail.value?.createTime,
  94. dateModified: detail.value?.updateTime,
  95. }),
  96. },
  97. ],
  98. link: [
  99. {
  100. rel: 'canonical',
  101. href: `${apiBaseSiteUrl}/blog/${slug}`,
  102. },
  103. ],
  104. })
  105. const { openLoginAndDownloadModal } = useLoginAndDownLoadModal()
  106. async function clickLoginAndDownload(item: any) {
  107. try {
  108. const commonStore = useCommonStore()
  109. commonStore.setDownloadCatalog(item)
  110. const { status } = await openLoginAndDownloadModal()
  111. if (status)
  112. location.reload()
  113. }
  114. catch (error) {
  115. console.log(error)
  116. }
  117. }
  118. </script>
  119. <template>
  120. <div class="blog-detail">
  121. <div class="bg-#F3F4FB ">
  122. <div class="pt-175px pb-110px w-1200-auto flex px-60px">
  123. <img :src="detail?.thumbnailUrl" :alt="detail?.thumbnailAlt" srcset="" class="w-410px h-256px b-rd-10px object-cover mr-40px">
  124. <div class="flex-1 text-left">
  125. <div class="b-rd-400px left-10px text-center w-138px h-32px lh-32px bg-#fff/50 backdrop-blur-20px b-1px b-solid b-#fff/60 text-#9B6CFF text-14px mb-20px">
  126. {{ detail.category_dictText }}
  127. </div>
  128. <h1
  129. class="!mb-20px fw-800 text-40px ls-2 text-#333 line-clamp-2 lh-50px custom-title-font"
  130. >
  131. {{ detail.contentTitle }}
  132. </h1>
  133. <div class="text-16px text-#999 lh-24px">
  134. {{ detail.contentSubhead }}
  135. </div>
  136. </div>
  137. </div>
  138. </div>
  139. <div class="w-1200-auto flex pt-30px">
  140. <div class="w-840px mr-60px">
  141. <div v-if="isHasCatalogue">
  142. <el-segmented v-model="tabValue" :options="options">
  143. <template #default="scope">
  144. <div>
  145. <div>{{ scope.item.label }}</div>
  146. </div>
  147. </template>
  148. </el-segmented>
  149. </div>
  150. <div v-show="tabValue === 'blog'" class="mt-30px content-detail custom-html" v-html="detail.content" />
  151. <div v-show="tabValue === 'catalog'" class="mt-30px">
  152. <iframe
  153. :src="`${detail?.relatedCatalogue?.viewPdf}#view=FitH&toolbar=0&scrollbar=0&navpanes=0`"
  154. allowfullscreen
  155. width="100%"
  156. height="1200px"
  157. style="border: none"
  158. >
  159. 您的浏览器不支持iframe,请使用现代浏览器查看PDF。
  160. </iframe>
  161. </div>
  162. </div>
  163. <div class="flex-1">
  164. <div v-if="isHasCatalogue" class="pos-relative mb-40px">
  165. <img :src="detail?.relatedCatalogue?.coverImg" :alt="detail?.relatedCatalogue?.coverAlt" srcset="" class="w-375px h-240px b-rd-10px object-cover">
  166. <h4
  167. class="!mb-15px !mt-30px fw-800 text-24px text-#333 line-clamp-2"
  168. >
  169. {{ detail?.relatedCatalogue?.title }}
  170. </h4>
  171. <div class="text-14px text-#999 lh-22px line-clamp-2 mb-20px">
  172. {{ detail?.relatedCatalogue?.subhead }}
  173. </div>
  174. <el-button class="!bg-#9B6CFF !text-#fff !b-#9B6CFF !b-rd-380px text-14px fw-bold !h-32px px-20px" @click="clickLoginAndDownload(detail?.relatedCatalogue)">
  175. {{ detail?.relatedCatalogue?.downloadCondition === Condition.REQUEST ? 'Request' : 'Download' }} Catalog
  176. </el-button>
  177. </div>
  178. <div v-if="!isLogin" class="px-40px pt-34px bg-#E7EAFF b-rd-10px text-center custom-main">
  179. <div class="text-#333 fw-500">
  180. Sign in for exclusive trending product catalogs!
  181. </div>
  182. <el-button class="mt-20px !bg-#fff !text-#9B6CFF !w-160px !h-40px !b-0px !b-rd-200px" round @click="openLoginModal">
  183. <span>
  184. Sign In
  185. </span>
  186. </el-button>
  187. </div>
  188. </div>
  189. </div>
  190. <common-block-blog class="!pb-0" />
  191. <AppFooter />
  192. </div>
  193. </template>
  194. <style lang='less' scoped>
  195. .el-segmented {
  196. --el-segmented-item-selected-color: #fff;
  197. --el-segmented-item-selected-bg-color: #9B6CFF;
  198. --el-border-radius-base: 16px;
  199. --el-segmented-bg-color: #F9FAFB;
  200. --el-segmented-color: #333;
  201. width: 100%;
  202. height: 68px;
  203. line-height: 68px;
  204. border-radius: 300px!important;
  205. overflow: hidden;
  206. padding: 0;
  207. ::v-deep .el-segmented__group {
  208. .el-segmented__item-selected,.el-segmented__item{
  209. border-radius: 300px!important;
  210. overflow: hidden;
  211. .el-segmented__item-label{
  212. font-size: 18px;
  213. }
  214. }
  215. }
  216. }
  217. .blog-detail {
  218. ::v-deep(.content-detail) {
  219. font-family: sans-serif;
  220. h2 {
  221. font-size: 1.5em;
  222. font-family: "CustomTitleFont";
  223. margin-top: 1em !important;
  224. margin-bottom: 1em !important;
  225. font-weight: bold;
  226. }
  227. h3 {
  228. display: block;
  229. font-size: 1.17em;
  230. margin-block-start: 1em;
  231. margin-block-end: 1em;
  232. margin-inline-start: 0px;
  233. margin-inline-end: 0px;
  234. margin-bottom: 1em !important;
  235. font-weight: bold;
  236. unicode-bidi: isolate;
  237. font-family: "CustomTitleFont";
  238. }
  239. p {
  240. display: block;
  241. margin-block-start: 1em;
  242. margin-block-end: 1em;
  243. margin-inline-start: 0px;
  244. margin-inline-end: 0px;
  245. unicode-bidi: isolate;
  246. }
  247. ul {
  248. display: block;
  249. list-style-type: disc;
  250. margin-block-start: 1em;
  251. margin-block-end: 1em;
  252. margin-inline-start: 0px;
  253. margin-inline-end: 0px;
  254. padding-inline-start: 40px;
  255. unicode-bidi: isolate;
  256. li {
  257. display: list-item;
  258. text-align: -webkit-match-parent;
  259. unicode-bidi: isolate;
  260. }
  261. }
  262. ol {
  263. list-style-type: decimal;
  264. display: block;
  265. list-style-type: decimal;
  266. margin-block-start: 1em;
  267. margin-block-end: 1em;
  268. margin-inline-start: 0px;
  269. margin-inline-end: 0px;
  270. padding-inline-start: 40px;
  271. unicode-bidi: isolate;
  272. }
  273. }
  274. }
  275. .custom-main{
  276. background: url('~/assets/images/swiper_bg.png') no-repeat center center;
  277. background-size: cover;
  278. width: 300px;
  279. height: 190px;
  280. }
  281. </style>